-
Notifications
You must be signed in to change notification settings - Fork 153
refactor: add batch content validation #1869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good for the most part, I don't know why we don't push up and now hide the decode errors in a few spots, but other then that the PR is clean
Since all the comments are on the same topic, I will just reply here. I don't think that logging or returning
So I decided to just return error that indicates that error happened because of the decoding (and not because of e.g. validation). I now added I'm not too set on this. If you think we should propagate error I can do so, but I would like to hear the argument for it. |
eef8d1e
to
9a420f3
Compare
Would we be able to embeded the debugging context in the ContentValidation::Invalid() instead of defining a debug! Message? I am not too picky I think logging it is definitely an improvement regardless. Up to you. It seems wasteful to have both though |
I am fine not propagating the error in this case, I agree what you did it higher value, my question is would anybody ever have the debug logs enabled. |
Anyways I am fine with whatever you decide, if it is a problem we can always change it later of course |
I don't want to embed debug message inside
Our prod nodes have If somebody is debugging this bug, they would enable it. Otherwise, it's probably not useful anyway. I will leave it as is, and we can change it in the future if needed. |
This was extracted from #1868
What was wrong?
Validator
is currently able to validate only one content at the time. This is not enough for ephemeral headers.Similar for
Store
when answering whether content is/should be stored.How was it fixed?
Rename
ContentStore::is_key_within_radius_and_unavailable
toContentStore::should_we_store
and addStore::should_we_store_batch
(for multiple items.Add
Validator::validate_content_batch
for validating multiple content items.Refactor
ValidationResult
:additional_content_to_propagate
from ValidationResult (it's not used)validate_content_batch
, because it isVec<ValidationResult>
instead ofVec<Result<ValidationResult>>
Invalid(String)
variant into more descriptive type, e.g.Invalid(ValidationFailureReason)
where:Future work
Start using batch functions from
offer.rs
(#1870) and add custom implementation of the batch functionality for history network (future PR).